<?php
/**
 * @Author: Marte
 * @Date:   2017-08-17 11:13:11
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-17 20:17:00
 */




if(isset($_GET['page']))
{
  $_page=$_GET['page'];
  if(empty($_page)||$_page<=0||!is_numeric($_page))
  {
     $_page=1;
  }
  else
  {
    $_page=intval($_page);//取整
  }
}
else
{
  $_page=1;
}
$_username=$_SESSION['username'];
$_pagesize=4;//每页有几条
$_pagenum=($_page-1)*$_pagesize;//每页第一个
mysqli_query($_mysql,"SELECT id FROM comment where send='$_username'");
// echo;
$_pagesnum=ceil(mysqli_affected_rows($_mysql)/$_pagesize);//共有几页
//如果$_page>总页数
if($_page>$_pagesnum)
{
  $_page=$_pagesnum;
}


// $_sql='select * from comment where send="'.$_username.'" order by id desc limit'. $_pagenum.','.$_pagesize .'';
$_result=mysqli_query($_mysql,"SELECT * FROM comment where send='$_username' order by id desc limit $_pagenum,$_pagesize ");

//谁【评论了我
if(isset($_GET['tome']))
{
  $_tome=$_GET['tome'];
  if(empty( $_tome)||$_tome||!is_numeric($_tome))
  {
     $_tome=1;
  }
  else
  {
     $_tome=intval( $_tome);//取整
  }
}
else
{
   $_tome=1;
}

$_pagesize=4;//每页有几条
$_pagenum1=($_tome-1)*$_pagesize;//每页第一个
mysqli_query($_mysql,"SELECT id FROM comment where receive='$_username'");
// echo;
$_pagesnum1=ceil(mysqli_affected_rows($_mysql)/$_pagesize);//共有几页
//如果$_page>总页数
if($_tome>$_pagesnum1)
{
  $_tome=$_pagesnum1;
}


// $_sql='select * from comment where send="'.$_username.'" order by id desc limit'. $_pagenum.','.$_pagesize .'';
$_result1=mysqli_query($_mysql,"SELECT * FROM comment where receive='$_username' order by id desc limit $_pagenum1,$_pagesize ");



?>
<span class="follow_title">我的动态</span>
<div class="follow_main">
    <span class="follow_s_title">我评论了谁</span><span class="follow_add"><a href="person.php?change=4" title=""><img src="images/jiahao.png" alt="">添加</a></span>

    <div class="allcomment_from_me">
        <ul class="start">


        <?php
            while($_assoc=$_result->fetch_assoc())
            {

                 $_sql0='select * from userregisters where username="'.$_assoc['receive'].'"';
                 $_result0=$_mysql->query($_sql0);
                 $_assoc0=$_result0->fetch_assoc();
        ?>
        <li>
            <i><img src="<?php echo $_assoc0['headicon']?>" alt=""></i>
            <div class="friend_main_right">
                <span class="username"><?php echo $_assoc0['nickname']?></span><em><img src="images/isgui.png" alt=""></em>
                <p><?php echo $_assoc['content']?></p>

                <span class="bottom_s label"><?php echo $_assoc0['rank']?></span>
                <span class="bottom_s not_label1"><a href="" name="message" title=""><?php echo $_assoc0['comment']?>人评论</a></span>
                <span class="bottom_s not_label2"><a href="" title=""><?php echo $_assoc0['zan']?>人点赞</a></span>
     <span class="bottom_s not_label3"><a href='' >关注</a></span>
            </div>
            <div class="clear">

            </div>
        </li>
        <?php

            }
        ?>


    </ul>
     <div class="clear">

    </div>

        <div class="num">
            <ul>
            <?php
                for($i=0;$i<$_pagesnum;$i++)
                {
                  echo '<li><a href="person.php?change=6&page='.($i+1).'">'.($i+1).'</a></li>';
                }
                echo '<li><a href="person.php?change=6&page='.($_page+1).'" >></a></li>';
            ?>


              <input type="text" name="" class="tiao" value="">
              <?php
                  echo "<script>$('.tiao').val()</script>"
              ?>
              <?php echo '<span class="go"><a href="person.php?change=6&page=

                  '."<script>$('.tiao').val();</script>".'
              " title=""></a>go</span>'?>
            </ul>
        </div>

    </div>
    <!-- 谁评论了我 -->
    <span class="follow_s_title">谁评论了我</span>

    <div class="allcomment_from_me">
        <ul class="start">


        <?php
            while($_assoc1=$_result1->fetch_assoc())
            {

                 $_sql00='select * from userregisters where username="'.$_assoc1['send'].'"';
                 $_result00=$_mysql->query($_sql00);
                 $_assoc00=$_result00->fetch_assoc();
        ?>
        <li>
            <i><img src="<?php echo $_assoc00['headicon']?>" alt=""></i>
            <div class="friend_main_right">
                <span class="username"><?php echo $_assoc00['nickname']?></span><em><img src="images/isgui.png" alt=""></em>
                <p><?php echo $_assoc1['content']?></p>

                <span class="bottom_s label"><?php echo $_assoc00['rank']?></span>
                <span class="bottom_s not_label1"><a href="" name="message" title=""><?php echo $_assoc00['comment']?>人评论</a></span>
                <span class="bottom_s not_label2"><a href="" title=""><?php echo $_assoc00['zan']?>人点赞</a></span>
     <span class="bottom_s not_label3"><a href='' >关注</a></span>
            </div>
            <div class="clear">

            </div>
        </li>
        <?php

            }
        ?>


    </ul>
     <div class="clear">

    </div>

        <div class="num">
            <ul>
            <?php
                for($i=0;$i<$_pagesnum1;$i++)
                {
                  echo '<li><a href="person.php?change=6&tome='.($i+1).'">'.($i+1).'</a></li>';
                }
                echo '<li><a href="person.php?change=6&tome='.($_page+1).'" >></a></li>';
            ?>



            </ul>
        </div>

    </div>
</div>